﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace OrderManagement
{
    [Serializable]
   public class Goods
    {
        public String Name { get; set; }       //商品名称
       public double Price { get; set; }       //商品单价
        public int Gperiod { get; set; }//保质期，以月为单位
        public int Num { get; set; }  //商品的数量
      
        public Goods(String Name,double Price,int Gperiod,int Num)
        {
            this.Name = Name;
            this.Price = Price;
            this.Gperiod = Gperiod;
            this.Num = Num;
        }
        public Goods() { }
        public override string ToString()
        {
            return ($"商品名称：{Name}，单价：{Price}元，保质期：{Gperiod}个月");
        }
        public override bool Equals(object obj)
        {
            Goods m = obj as Goods;
            return m != null && m.Gperiod == this.Gperiod && m.Name == this.Name && this.Num == m.Num;
        }

        public override int GetHashCode()
        {
            int hashCode = 941578986;
            hashCode = hashCode * -1521134295 + EqualityComparer<string>.Default.GetHashCode(Name);
            hashCode = hashCode * -1521134295 + Price.GetHashCode();
            hashCode = hashCode * -1521134295 + Gperiod.GetHashCode();
            hashCode = hashCode * -1521134295 + Num.GetHashCode();
            return hashCode;
        }
    }
}
